import { _decorator, SpriteAtlas } from 'cc';
import { BaseClass } from '../../../Framework/Scripts/Managers/BaseClass';
import { GameUtils } from '../../../Framework/Scripts/Utils/GameUtils';
import { INetCfg, IUserInfo } from '../Config/CommonProto';

export class GameData extends BaseClass {
    public userInfo: IUserInfo;

    public atalsPlay: SpriteAtlas = null;

    //大厅服务的网络配置
    public hallNetCfg:INetCfg = {
        ip: '',
        port: 0
    };
    //游戏服务的网络配置
    public gameNetCfg:INetCfg = {
        ip: '',
        port: 0
    };

    public defaultName = '默认';
    //默认图片
    public defaultLogo = 'https://copyright.bdstatic.com/vcg/creative/cc9c744cf9f7c864889c563cbdeddce6.jpg@h_1280';

    private static _inst: GameData;
    public static get inst(): GameData {
        if (this._inst == null) {
            this._inst = new GameData();
        }

        return this._inst;
    }

    constructor() {
        super()    
        
        this.Init();
    }

    private Init(){
        let userInfo:IUserInfo ={
            userId: '',
            name: '',
            avator: '',
            ballNum: 0,
            ticket: 0,
            ranks: 0,
            score: 0
        }
        this.userInfo = userInfo;
    }

    //保存用户数据
    public setUserInfo(user:IUserInfo){
        this.userInfo = GameUtils.deepClone(user);
    }
}


